import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Home from "../views/Home.vue";
import Index from "../views/Index.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "Home",
    component: Index,
    children: [
      { path: "", name: "home", component: Home, meta: { title: "欢迎" } },
      {
        path: "template/:id",
        name: "template",
        component: () => import("../views/TemplateDetail.vue"),
        meta: { title: "模版详情" },
      },
    ],
  },
  {
    path: "/editor/:id",
    name: "editor",
    component: () =>
      import(/* webpackChunkName: "editor" */ "../views/Editor.vue"),
    meta: { requiredLogin: true, title: "编辑我的设计" },
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
